{"ast":null,"code":"import _objectSpread from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/objectSpread2.js\";import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from'react';import{Home}from\"../../\";import{Circle}from'rc-progress';import{observer}from\"mobx-react-lite\";import{Context}from\"../../../index\";import{profileCompletionPercentage}from\"../../../utils/User\";import Switch from'@mui/material/Switch';import{Button,UserProfile,Modal,Error}from'../../../components';import{ChangeProfileForm}from'../../../modules/';import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";var Profile=function Profile(){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var _React$useState=React.useState(0),_React$useState2=_slicedToArray(_React$useState,2),profilePercent=_React$useState2[0],setProfilePercent=_React$useState2[1];var _React$useState3=React.useState(true),_React$useState4=_slicedToArray(_React$useState3,2),disableToggle=_React$useState4[0],setDisableToggle=_React$useState4[1];var _React$useState5=React.useState(false),_React$useState6=_slicedToArray(_React$useState5,2),showModal=_React$useState6[0],setShowModal=_React$useState6[1];var _React$useState7=React.useState(false),_React$useState8=_slicedToArray(_React$useState7,2),showUserEdit=_React$useState8[0],setShowUserEdit=_React$useState8[1];var memoizedProfile=React.useMemo(function(){return profileCompletionPercentage(store.getProfile());},// eslint-disable-next-line react-hooks/exhaustive-deps\n[store.getProfile()]);React.useEffect(function(){setProfilePercent(memoizedProfile);},[store.getProfile()]);return/*#__PURE__*/_jsx(Home,{childrenFirst:/*#__PURE__*/_jsxs(\"div\",{className:\"messenger__sidebar-item\",children:[/*#__PURE__*/_jsx(\"div\",{className:\"messenger__sidebar-item-header\",children:/*#__PURE__*/_jsx(\"div\",{className:\"messenger__sidebar-item-header-top\",children:/*#__PURE__*/_jsx(\"span\",{children:\"\\u041D\\u0430\\u0441\\u0442\\u0440\\u043E\\u0439\\u043A\\u0438 \\u043F\\u0440\\u043E\\u0444\\u0438\\u043B\\u044F\"})})}),/*#__PURE__*/_jsxs(\"div\",{className:\"messenger__sidebar-profile\",children:[/*#__PURE__*/_jsx(Circle,{percent:profilePercent,strokeWidth:3,className:\"messenger__sidebar-profile-progress\"}),/*#__PURE__*/_jsxs(\"p\",{className:\"messenger__sidebar-profile-progressInfo\",children:[\"\\u041F\\u0440\\u043E\\u0444\\u0438\\u043B\\u044C \\u0437\\u0430\\u043F\\u043E\\u043B\\u043D\\u0435\\u043D \\u043D\\u0430: \",profilePercent.toString().slice(0,5),\"%\"]})]}),/*#__PURE__*/_jsxs(\"div\",{className:\"messenger__sidebar-profileControl\",children:[/*#__PURE__*/_jsxs(\"div\",{className:\"messenger__sidebar-profileControl-top\",children:[/*#__PURE__*/_jsx(Switch,{checked:!disableToggle,onChange:function onChange(){return setDisableToggle(!disableToggle);},name:\"special\"}),/*#__PURE__*/_jsx(\"span\",{className:\"messenger__sidebar-profileControl-top-toggleInfo\",children:\"\\u0421\\u043F\\u0435\\u0446\\u0438\\u0430\\u043B\\u044C\\u043D\\u044B\\u0435 \\u0432\\u043E\\u0437\\u043C\\u043E\\u0436\\u043D\\u043E\\u0441\\u0442\\u0438\"})]}),/*#__PURE__*/_jsxs(\"div\",{className:\"messenger__sidebar-profileControl-main\",children:[/*#__PURE__*/_jsx(Button,{customClassName:\"messenger__sidebar-profileControl-changeProfile\",fullWidth:false,text:!disableToggle?'Изменить профиль':'',disable:disableToggle,callback:function callback(){return setShowUserEdit(!showUserEdit);}}),/*#__PURE__*/_jsx(Button,{customClassName:\"messenger__sidebar-profileControl-deleteProfile\",fullWidth:false,text:!disableToggle?'Удалить профиль':'',disable:disableToggle,callback:function callback(){return setShowModal(!showModal);}})]})]}),/*#__PURE__*/_jsx(Modal,{active:showModal,title:\"Удаление профиля\",hasFunctionButtons:true,onSubmit:function onSubmit(){return store.deleteProfileFromAPI();},onClose:function onClose(){return setShowModal(false);},customClassNameButtonSecond:\"messenger__sidebar-profileControl-deleteProfile\",children:/*#__PURE__*/_jsx(\"div\",{children:\"\\u0412\\u044B \\u0434\\u0435\\u0439\\u0441\\u0442\\u0432\\u0438\\u0442\\u0435\\u043B\\u044C\\u043D\\u043E \\u0445\\u043E\\u0442\\u0438\\u0442\\u0435 \\u0431\\u0435\\u0437\\u0432\\u043E\\u0437\\u0432\\u0440\\u0430\\u0442\\u043D\\u043E \\u0443\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u043F\\u0440\\u043E\\u0444\\u0438\\u043B\\u044C?\"})}),/*#__PURE__*/_jsx(Error,{text:'Пользователь с таким псевдонимом уже существует!'})]}),childrenSecond:!showUserEdit&&/*#__PURE__*/_jsx(\"div\",{className:\"messenger__imProfile\",children:store.getProfile().id&&/*#__PURE__*/_jsx(UserProfile,{profile:_objectSpread({},store.getProfile()),selfProfile:true})})||/*#__PURE__*/_jsx(\"div\",{className:\"messenger__imProfile\",children:store.getProfile().id&&/*#__PURE__*/_jsx(ChangeProfileForm,{cancel:function cancel(){return setShowUserEdit(false);},profile:store.getProfile()})})});};export default observer(Profile);","map":{"version":3,"names":["React","Home","Circle","observer","Context","profileCompletionPercentage","Switch","Button","UserProfile","Modal","Error","ChangeProfileForm","Profile","useContext","store","useState","profilePercent","setProfilePercent","disableToggle","setDisableToggle","showModal","setShowModal","showUserEdit","setShowUserEdit","memoizedProfile","useMemo","getProfile","useEffect","toString","slice","deleteProfileFromAPI","id"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/pages/Home/Profile/index.tsx"],"sourcesContent":["import React from 'react';\nimport {Home} from \"../../\";\nimport  {Circle} from 'rc-progress';\nimport {observer} from \"mobx-react-lite\";\nimport {Context} from \"../../../index\";\nimport {profileCompletionPercentage} from \"../../../utils/User\";\nimport Switch from '@mui/material/Switch';\nimport {Button, UserProfile, Modal, Error} from '../../../components'\nimport {ChangeProfileForm} from '../../../modules/';\n\nconst Profile = () => {\n    const {store} = React.useContext(Context);\n    const [profilePercent, setProfilePercent] = React.useState<number>(0);\n    const [disableToggle, setDisableToggle] = React.useState<boolean>(true);\n    const [showModal, setShowModal] = React.useState<boolean>(false);\n    const [showUserEdit, setShowUserEdit] = React.useState<boolean>(false);\n\n    const memoizedProfile = React.useMemo(\n        () => profileCompletionPercentage(store.getProfile()),\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n        [store.getProfile()]\n    );\n\n    React.useEffect(() => {\n        setProfilePercent(memoizedProfile);\n    },[store.getProfile()]);\n\n    return (\n        <Home\n            childrenFirst={\n                <div className=\"messenger__sidebar-item\">\n                    <div className=\"messenger__sidebar-item-header\">\n                        <div className=\"messenger__sidebar-item-header-top\">\n                            <span>Настройки профиля</span>\n                        </div>\n                    </div>\n                    <div className=\"messenger__sidebar-profile\">\n                        <Circle\n                            percent={profilePercent}\n                            strokeWidth={3}\n                            className=\"messenger__sidebar-profile-progress\"\n                        />\n                        <p className=\"messenger__sidebar-profile-progressInfo\">\n                            Профиль заполнен на: {profilePercent.toString().slice(0, 5)}%\n                        </p>\n                    </div>\n                    <div className=\"messenger__sidebar-profileControl\">\n                        <div className=\"messenger__sidebar-profileControl-top\">\n                            <Switch\n                                checked={!disableToggle}\n                                onChange={() => setDisableToggle(!disableToggle)}\n                                name=\"special\"\n                            />\n                            <span className=\"messenger__sidebar-profileControl-top-toggleInfo\">\n                                Специальные возможности\n                            </span>\n                        </div>\n                        <div className=\"messenger__sidebar-profileControl-main\">\n                            <Button\n                                customClassName=\"messenger__sidebar-profileControl-changeProfile\"\n                                fullWidth={false}\n                                text={!disableToggle?'Изменить профиль':''}\n                                disable={disableToggle}\n                                callback={() => setShowUserEdit(!showUserEdit)}\n                            />\n                            <Button\n                                customClassName=\"messenger__sidebar-profileControl-deleteProfile\"\n                                fullWidth={false}\n                                text={!disableToggle?'Удалить профиль':''}\n                                disable={disableToggle}\n                                callback={() => setShowModal(!showModal)}\n                            />\n                        </div>\n                    </div>\n                    <Modal\n                        active={showModal}\n                        title={\"Удаление профиля\"}\n                        hasFunctionButtons={true}\n                        onSubmit={() => store.deleteProfileFromAPI()}\n                        onClose={() => setShowModal(false)}\n                        customClassNameButtonSecond={\"messenger__sidebar-profileControl-deleteProfile\"}\n                    >\n                        <div>Вы действительно хотите безвозвратно удалить профиль?</div>\n                    </Modal>\n                    <Error text={'Пользователь с таким псевдонимом уже существует!'} />\n                </div>\n            }\n            childrenSecond={\n                (!showUserEdit &&\n                    <div className=\"messenger__imProfile\">\n                        {store.getProfile().id && <UserProfile profile={{...store.getProfile()}} selfProfile={true} />}\n                    </div>) ||\n                <div className=\"messenger__imProfile\">\n                    {store.getProfile().id && <ChangeProfileForm\n                        cancel={() => setShowUserEdit(false)}\n                        profile={store.getProfile()}\n                    />}\n                </div>\n            }\n        />\n    );\n}\n\nexport default observer(Profile);"],"mappings":"2RAAA,MAAOA,MAAK,KAAM,OAAO,CACzB,OAAQC,IAAI,KAAO,QAAQ,CAC3B,OAASC,MAAM,KAAO,aAAa,CACnC,OAAQC,QAAQ,KAAO,iBAAiB,CACxC,OAAQC,OAAO,KAAO,gBAAgB,CACtC,OAAQC,2BAA2B,KAAO,qBAAqB,CAC/D,MAAOC,OAAM,KAAM,sBAAsB,CACzC,OAAQC,MAAM,CAAEC,WAAW,CAAEC,KAAK,CAAEC,KAAK,KAAO,qBAAqB,CACrE,OAAQC,iBAAiB,KAAO,mBAAmB,CAAC,wFAEpD,GAAMC,QAAO,CAAG,QAAVA,QAAO,EAAS,CAClB,sBAAgBZ,KAAK,CAACa,UAAU,CAACT,OAAO,CAAC,CAAlCU,KAAK,mBAALA,KAAK,CACZ,oBAA4Cd,KAAK,CAACe,QAAQ,CAAS,CAAC,CAAC,oDAA9DC,cAAc,qBAAEC,iBAAiB,qBACxC,qBAA0CjB,KAAK,CAACe,QAAQ,CAAU,IAAI,CAAC,qDAAhEG,aAAa,qBAAEC,gBAAgB,qBACtC,qBAAkCnB,KAAK,CAACe,QAAQ,CAAU,KAAK,CAAC,qDAAzDK,SAAS,qBAAEC,YAAY,qBAC9B,qBAAwCrB,KA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